﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;

namespace SlamCms.SharePoint.Migration
{
	public class MigratableFieldList : List<MigratableField>, IMigratable
	{
		public XElement ToXml()
		{
			XElement node = new XElement("Fields");
			foreach (MigratableField f in this)
			{
				node.Add(f.ToXml());
			}
			return node;
		}

		public void FromXml(XElement element)
		{
			var fieldsNode = element.Element("Fields");
			if (fieldsNode.HasElements)
			{
				foreach (XElement child in fieldsNode.Elements())
				{
					MigratableField field = new MigratableField();
					field.FromXml(child);
					this.Add(field);
				}
			}
		}
	}
}
